<?php


namespace App\Http\Controllers\Flow;
use App\Exceptions\APIHttpException;
use App\Http\Controllers\Controller;
use App\Http\Model\Flow\BackupMoneyApplyModel;
use App\Http\Model\Common\BusinessModel;
use App\Http\Middleware\Auth;

class BackupMoneyApply extends Controller
{
    /*
     * 6.4-备份金申请接口流水查询-列表
     * {
            "page": 1,
            "pagesize": 20,
            "status":"处理成功",
            “city_name”:"合肥",
            “ledger_subject_name”:"主体名称“,
            "collect_ctime":"2021-06-01",
            "collect_etime":"2021-06-10"
        }
     *
    */
    public function index(){
        $input = $this->_auth();
        $func = __FUNCTION__;
        $ret = BackupMoneyApplyModel::$func($input);
        return APIHttpException::success($ret);
    }
    /*导出*/
    public function export(){
        $input = $this->_auth();
        BackupMoneyApplyModel::index($input);
    }
    /*
     * 处理权限
     */
    private function _auth(){

        $input = request()->all();

        $pfs_dw_id = Auth::pfs([$input['pfs_dw_id']], 0);
        if(empty($pfs_dw_id)){
            throw new APIHttpException('没有权限~');
        }
        /*监管银行账号组*/
        $input['pfs_dw_id'] = explode(',',$pfs_dw_id);

        return $input;
    }
}
